package Exercise;

public class MathExe1 {
    //判断质数
    //小于等于平方根 大于等于平方根
    public static boolean Judge(int a) {
        for (int i = 2; i <=/*包含平方根*/ Math.sqrt(a); i++) {
            if (a % i == 0) {
                return false;
            }
        }
        return true;
    }

    public static boolean JudgeZiMi(int a) {
        int t = a;
        int count = 0;
        int sum = 0;
        int tmp = 1;
        while (t != 0) {
            count++;
            t /= 10;
        }
        t = a;
        for (int i = 0; i < count; i++) {
            for (int i1 = 0; i1 < count; i1++) {
                tmp *= (t % 10);
            }
            sum += tmp;
            tmp = 1;
            t /= 10;
        }
        return sum == a;
    }

    public static boolean MathZiMi(double a) {
        int count = 0;
        double sum=0;
        double t=a;
        while (t != 0) {
            count++;
            t=Math.floor(t/10);
        }
        t=a;
        for (int i = 0; i < count; i++) {
            sum+=(Math.pow((t%10),count));
            t=Math.floor(t/10);
        }
        return a==sum;
    }
}
